<template>
  <div>
    <div class="description">
      <p class="title">您需要什么样的服务？</p>
    </div>
    <div class="form">
      <p class="name">系统服务</p>
      <ul class="plat-forms clearfix system">
        <li v-for="item in systems" :key="item.id">
          <input type="checkbox" :id="item.id" name="system" :checked="checkedSys.indexOf(item.id) != -1" :value="item.id" @change="setSysChecked(item.id,item.name)">
          <label :for="item.id">
            <div class="icon" :class="{icon_computer: item.id == '6', icon_wx: item.id == '7',icon_mini: item.id == '8',icon_app: item.id == '9'}"></div>
            <em>{{item.name}}</em>
          </label>
        </li>
      </ul>
    </div>
    <div class="form">
      <p class="name">单一服务</p>
      <ul class="plat-forms clearfix single">
        <li v-for="item in singles" :key="item.id">
          <input type="radio" :id="item.id" name="single" :checked="item.id == checkedSing" :value="item.id" v-model="checkedSing" @change="setSingChecked(item.id)">
          <label :for="item.id">
            <p>{{item.title}}<p/>
            <p>{{item.detail}}</p>
          </label>
        </li>
      </ul>
    </div>
    <div class="next-btn">
        <router-link v-if="develop_model == 1" class="button next" to="/quote/step2">
          下一步
        </router-link>

        <router-link v-if="develop_model == 2" class="button next" to="/quote/step2Setting">
          下一步
        </router-link>
    </div>
  </div>
</template>

<script>
  import axios from 'axios'
  export default{
    name:'step1',
    created: function() {
         var that=this;
          axios.post(this.HOST+'/api/Index/getAppCategory')
              .then(function (response) {
                  var info=response.data.data.info;
                  that.systems=info.list1;
                  that.singles=info.list2;
              })
              .catch(function (response) {
                  console.log(response);
              });
    },
    data() {
      return {
        systems: [],
        develop_model:1,
        checkedSys: [],            //复选框选中值
        checkedSysObj:[],
        checkedSing: "",            //单选框的值
        singles: []
      }
    },
    methods: {
      setSysChecked(id,name) {
          this.checkedSing="";
          this.develop_model=1;
          var obj={};
          if(this.checkedSys.indexOf(id)==-1){
              this.checkedSys.push(id);
              obj.id=id;
              obj.name=name;
              this.checkedSysObj.push(obj);
          }
          localStorage.setItem('cate_id','');
          localStorage.setItem('checkedSysObj',JSON.stringify(this.checkedSysObj));
          localStorage.setItem('develop_model',1);
      },
      setSingChecked(id) {
          this.develop_model=2;
          this.checkedSing=id;
          this.checkedSys=[];
          localStorage.setItem('checkedSysObj','');
          localStorage.setItem('cate_id',id);
          localStorage.setItem('develop_model',2);
      }
    },

  }
</script>

<style scoped>

  .description {
    margin: 2rem auto;
    max-width: 980px;
  }
  .description p.title {
    color: #2d3238;
    font-weight: 200;
    font-size: 2.4rem;
    margin: 0 0 1rem;
  }
  .form {
    margin: 50px auto 0;
  }
  .form p.name {
    font-size: 1.6rem;
    text-align: center;
    margin-bottom: 20px;
  }
  .form .plat-forms {
    list-style: none;
    padding: 0;
    margin: 00px auto;
    max-width: 980px;
  }
  .plat-forms li {
    width: calc((100% - 2 * 1.7rem) / 3);
    position: relative;
    height: 11.6rem;
    margin: 0 1.1rem 1rem 0;
    float: left;
    color: #979fa8;
    cursor: pointer;
    background: #fff;
    border-radius: .4rem;
    text-align: center;
    overflow: hidden;
  }
  .plat-forms.single li:nth-child(3n + 3) {
    margin-right: 0;
  }
  .plat-forms li label {
    display: inline-block;
     width: 100%;
     height: 100%;
     padding: 1rem;
     cursor: pointer;
  }
  .plat-forms li input[type="checkbox"], .plat-forms li input[type="radio"] {
    position: absolute;
    top: 0;
    visibility: hidden;
}
   .plat-forms li input[type="checkbox"]:checked + label, .plat-forms li input[type="radio"]:checked + label {
    background: #4289db;
    color: #fff;
  }
  .plat-forms li:hover {
    background: #4289db;
    color: #fff;
  }
  .plat-forms li lable {
    display: inline-block;
    width: 100%;
    height: 100%;
    position: relative;
  }

  .plat-forms.system li {
    width: calc((100% - 3 * 1.7rem) / 4);
  }

  .plat-forms.system li:nth-child(4n + 4) {
    margin-right: 0;
  }
  .plat-forms li em {
    display: block;
    font-style: normal;
    font-size: 1rem;
    color: inherit;
    line-height: 1.2rem;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 2rem;
    text-align: center;
    margin-top: 1rem;
  }
  .plat-forms li div.icon {
    height: 6rem;
    margin-top: 0.2rem;
  }
  .plat-forms li div.icon_computer{
    background: url("../../assets/img/quote_computer.png") no-repeat center;
  }
  .plat-forms li div.icon_wx {
    background: url("../../assets/img/quote_wx.png") no-repeat center;
  }
  .plat-forms li div.icon_mini {
    background: url("../../assets/img/quote_mini.png") no-repeat center;
  }
  .plat-forms li div.icon_app {
    background: url("../../assets/img/quote_app.png") no-repeat center;
  }

  .plat-forms li:hover div.icon_computer, .plat-forms li input[type="checkbox"]:checked + label div.icon_computer {
    background: url("../../assets/img/quote_computer_hover.png") no-repeat center;
  }
  .plat-forms li:hover div.icon_wx, .plat-forms li input[type="checkbox"]:checked + label div.icon_wx {
    background: url("../../assets/img/quote_wx_hover.png") no-repeat center;
  }
  .plat-forms li:hover div.icon_mini, .plat-forms li input[type="checkbox"]:checked + label div.icon_mini {
    background: url("../../assets/img/quote_mini_hover.png") no-repeat center;
  }
  .plat-forms li:hover div.icon_app, .plat-forms li input[type="checkbox"]:checked + label div.icon_app {
    background: url("../../assets/img/quote_app_hover.png") no-repeat center;
  }
 
  .plat-forms.single li p {
    font-size: 1rem;
    line-height: 1.5rem;
  }
  .plat-forms.single li p:first-child {
    margin-top: 2.2rem;
    margin-bottom: 0.6rem;
    font-size: 1.4rem;
    line-height: 2.5rem;
  }
  .next-btn {
    margin: 2.5rem auto;
    text-align: center;
  }
  .next-btn .button {
    width: 33%;
    height: 4.1rem;
    line-height: 2.1rem;
    font-size: 1.5rem;
    min-width: 17rem;
    background: #4289db;
    color: #fff;
    cursor: pointer;
    border-radius: .4rem;
    border: 0;
    box-shadow: 0 3px 3px rgba(45,51,56,.2);
    outline: none;
  }
  .next-btn .next {
    color: #fff;
    display: inline-block;
    line-height: 4.1rem;
  }


</style>
